package com.husawang.husa.lib.base.utils;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.telephony.TelephonyManager;

import com.husawang.husa.lib.base.MyApplication;

/**
 * Created by s on 2017/8/8.
 */

public class HusaUtils {

	private static HusaUtils mHusaUtils;

	private HusaUtils() {
	}

	public static HusaUtils getInstance() {
		if (mHusaUtils==null){
			return new HusaUtils();
		}
		return mHusaUtils;
	}


	public String[] getPhoneInfo() {
		TelephonyManager mTm = (TelephonyManager) MyApplication.getInstance().getSystemService(Context.TELEPHONY_SERVICE);
		String imei = mTm.getDeviceId();
		String imsi = mTm.getSubscriberId();
		String mtype = android.os.Build.MODEL; // 手机型号
		String mtyb = android.os.Build.BRAND;//手机品牌
		String numer = mTm.getLine1Number(); // 手机号码，有的可得，有的不可得
		String[] androidInfo = new String[]{imei, imsi, mtype, mtyb, numer};
//		KJLoger.log(TAG, "手机IMEI号：" + imei + "手机IESI号：" + imsi + "手机型号：" + mtype + "手机品牌：" + mtyb + "手机号码" + numer);
		return androidInfo;
	}

	public String getPhoneVersion() {
		try {
			PackageManager manager = MyApplication.getInstance().getPackageManager();
			PackageInfo info = manager.getPackageInfo(MyApplication.getInstance().getPackageName(), 0);
			String version = info.versionName;
			return version;
		} catch (Exception e) {
			e.printStackTrace();
			return "1.0";
		}
	}
}
